package cc.bukkitPlugin.banitem.command;

import java.util.ArrayList;

import org.bukkit.command.CommandSender;

import cc.bukkitPlugin.banitem.BanItem;
import cc.bukkitPlugin.banitem.CFG;
import cc.bukkitPlugin.banitem.manager.ItemManager;
import cc.bukkitPlugin.util.plugin.command.TCommandReload;

public class CommandReload extends TCommandReload<BanItem>{

    public CommandReload(CommandExc pExector){
        super(pExector);
        this.mSubCommand.add("list");
    }

    @Override
    public boolean execute(CommandSender pSender,String pLabel,String[] pArgs){
        if(pArgs.length>1)
            return errorArgsNumber(pSender,pArgs.length);
        String cmdLabel="all";
        if(pArgs.length>0)
            cmdLabel=pArgs[0];
        if(cmdLabel.equalsIgnoreCase("list")){
            if(!pSender.hasPermission(this.mPluginName+".reload.list"))
                return noPermission(pSender);
            this.mPlugin.getManager(ItemManager.class).reloadConfig(pSender);
            return true;
        }else return super.execute(pSender,pLabel,pArgs);
    }

    @Override
    public ArrayList<String> getHelp(CommandSender sender,String pLabel){
        ArrayList<String> list=new ArrayList<>();
        if(sender.hasPermission(this.mPluginName+".reload.all")){
            list.add(CFG.cmd_color+this.mMainCmdLabel+" reload [all]");
            list.add(CFG.help_color+this.C("HelpReloadPlugin"));
        }
        if(sender.hasPermission(this.mPluginName+".reload.config")){
            list.add(CFG.cmd_color+this.mMainCmdLabel+" reload config");
            list.add(CFG.help_color+this.C("HelpReloadConfig"));
        }
        if(sender.hasPermission(this.mPluginName+".reload.lang")){
            list.add(CFG.cmd_color+this.mMainCmdLabel+" reload lang");
            list.add(CFG.help_color+this.C("HelpReloadLang"));
        }
        if(sender.hasPermission(this.mPluginName+".reload.list")){
            list.add(CFG.cmd_color+this.mMainCmdLabel+" reload list");
            list.add(CFG.help_color+"重新加载黑名单,禁用列表,NBT检查名单");
        }
        return list;
    }

}
